<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="main.xsl"/>
<xsl:template name="content">

<table width="100%" border="0" cellspacing="0" cellpadding="0">
   <tr>
    <td colspan="2">
        <xsl:if test="user_validation">
            <div class="error">This form is contains errors. <br/>Please check highlighted fields.</div>            
        </xsl:if>
    </td>
  </tr>
  <tr>
    <td>
      <form name="user_add" method="post" action="/admin/security/user/edit&amp;user_id={//_get/user_id}">
	  <xsl:if test="//_get/user_id">
	  <input type="hidden" name="user_id" value="{//_get/user_id}"/>
	  </xsl:if>
        <table width="100%" border="0" cellspacing="0" cellpadding="3">
          <tr align="center">
            <td colspan="2"><b>User Add/Edit</b></td>
          </tr>
          <tr> 
            <td align="right">
                <xsl:if test="user_validation/name/failed">
                <xsl:attribute name="class">error</xsl:attribute>
                </xsl:if>Prefix</td>
            <td>
              <input type="text" name="prefix" value="{_post/prefix|//get_user_by_id/prefix}" size="5"/>
            </td>
          </tr>          
          <tr> 
            <td align="right">
                <xsl:if test="user_validation/name/failed">
                <xsl:attribute name="class">error</xsl:attribute>
                </xsl:if>First Name*</td>
            <td>
              <input type="text" name="first_name" value="{_post/first_name|//get_user_by_id/first_name}" size="25"/>
            </td>
          </tr>  
          <tr> 
            <td align="right">
                <xsl:if test="user_validation/name/failed">
                <xsl:attribute name="class">error</xsl:attribute>
                </xsl:if>Middle Name</td>
            <td>
              <input type="text" name="middle_name" value="{_post/middle_name|//get_user_by_id/middle_name}" size="25"/>
            </td>
          </tr>  
          <tr> 
            <td align="right">
                <xsl:if test="user_validation/name/failed">
                <xsl:attribute name="class">error</xsl:attribute>
                </xsl:if>Last Name*</td>
            <td>
              <input type="text" name="last_name" value="{_post/last_name|//get_user_by_id/last_name}" size="25"/>
            </td>
          </tr>  
          <tr> 
            <td align="right">
                <xsl:if test="user_validation/name/failed">
                <xsl:attribute name="class">error</xsl:attribute>
                </xsl:if>Suffix</td>
            <td>
              <input type="text" name="suffix" value="{_post/suffix|//get_user_by_id/suffix}" size="5"/>
            </td>
          </tr>                 
           <tr> 
            <td align="right">
                <xsl:if test="user_validation/email/failed">
                <xsl:attribute name="class">error</xsl:attribute>
                </xsl:if>Email*</td>
            <td>
              <input type="text" name="email" value="{_post/email|//get_user_by_id/email}" size="25"/>
            </td>
          </tr>
          <tr> 
            <td align="right"><xsl:if test="user_validation/user_name/failed">
                <xsl:attribute name="class">error</xsl:attribute>
                </xsl:if>Username*</td>
            <td>
              <input type="text" name="user_name" value="{_post/user_name|//get_user_by_id/user_name}" size="25"/>
            </td>
          </tr>
		  <xsl:if test="not(//get_user_by_id/user_name)">
           <tr> 
            <td align="right">
                <xsl:if test="user_validation/user_password/failed">
                <xsl:attribute name="class">error</xsl:attribute>
                </xsl:if>Password*</td>
            <td>
              <input type="password" name="user_password"  size="25"/>
            </td>
          </tr>
         <tr> 
            <td align="right">Password confirm*</td>
            <td>
              <input type="password" name="user_password_match" size="25"/>
            </td>
          </tr>
		  </xsl:if>
		  <tr>
		  	<td align="right">Account</td>
			<xsl:if test="//get_user_account_by_id/name">
			<td><xsl:value-of select="//get_user_account_by_id/name"/></td>
			</xsl:if>
			<xsl:if test="not(//get_user_account_by_id/name)">
			<td><select name="employer_id">
			<xsl:for-each select="//get_all_accounts">
				<option value="{employer_id}"><xsl:value-of select="name"/></option>
			</xsl:for-each>
			</select></td>
			</xsl:if>
		  </tr>
          <tr>
            <td align="right" valign="top">
                <xsl:if test="user_validation/group_id/failed">
                <xsl:attribute name="class">error</xsl:attribute>
                </xsl:if>Groups*</td>
            <td>
              <xsl:for-each select="//get_account_groups">

                <input type="checkbox" name="group_id[]" value="{group_id}">
                    <xsl:if test="(group_id=//_post/group_id) or (group_id=//get_user_groups_by_id/group_id)">
                        <xsl:attribute name="checked">checked</xsl:attribute>
                    </xsl:if>
                </input>
                    <xsl:value-of select="name"/><br/>
            </xsl:for-each>
            
            </td>
          </tr>
          <tr> 
            <td></td>
            <td align="center">
              <input type="submit" name="submit" value="Submit"/>
            </td>
          </tr>
        </table>
      </form>
    </td>
  </tr>
</table>

</xsl:template>


</xsl:stylesheet>

